package com.yikes.srb.controller.web;

import com.yikes.srb.common.result.PageResult;
import com.yikes.srb.common.result.Result;
import com.yikes.srb.leadingModle.form.srbPermitFile.SrbPermitFileAddForm;
import com.yikes.srb.leadingModle.form.srbPermitFile.SrbPermitFileEditForm;
import com.yikes.srb.leadingModle.form.srbPermitFile.SrbPermitFileQuery;
import com.yikes.srb.leadingModle.vo.SrbPermitFileVO;
import com.yikes.srb.service.SrbPermitFileService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * yikes上传附件表 前端控制器
 * </p>
 *
 * @author guanrong.yin
 * @since 2024-12-03
 */
@RequiredArgsConstructor
@Tag(name = "SrbPermitFileController", description = "yikes上传附件表")
@RestController
@RequestMapping("/admin/srb_permit_file")
public class SrbPermitFileController {

    private final SrbPermitFileService service;


    @Operation(description = "分页查询")
    @GetMapping("/list_page")
    public Result<PageResult<SrbPermitFileVO>> listPage(SrbPermitFileQuery query) {

        return Result.ok(service.listPage(query));
    }

    @Operation(description = "根据id查询单条信息")
    @GetMapping("/info/{id}")
    public Result<SrbPermitFileVO> infoId(@PathVariable("id") Long id) {

        return Result.ok(service.infoId(id));
    }

    @Operation(description = "新增")
    @PostMapping("/create")
    public Result create(@Valid @RequestBody SrbPermitFileAddForm form) {

        service.create(form);
        return Result.ok();
    }

    @Operation(description = "编辑")
    @PutMapping("/edit")
    public Result edit(@Valid @RequestBody SrbPermitFileEditForm form) {

        service.edit(form);
        return Result.ok();
    }

    @Operation(description = "删除")
    @DeleteMapping("/del/{id}")
    public Result del(@PathVariable("id") Long id) {

        service.del(id);
        return Result.ok();
    }

}
